package servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import dao.GetUserIdByUsernameDao;
import dao.MessageDao;
import dao.impl.GetUserIdByUsernameDaoImpl;
import dao.impl.MessageDaoImpl;
import entity.Product_Comment;
import entity.User_Inf;

public class Product_CommentServlet extends HttpServlet {
	private GetUserIdByUsernameDao gu = new GetUserIdByUsernameDaoImpl();
	MessageDao ad = new MessageDaoImpl();
	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html;charset=utf-8");
		String product_id = request.getParameter("product_id");//商品id
		String username = request.getParameter("username");//用户
		String user_id = request.getParameter("user_id");//用户
		String content = request.getParameter("content");//评论内容
		String perfume = request.getParameter("perfume");//商品
		String model = request.getParameter("model");//型号
		String color = request.getParameter("color");//不要颜色
		PrintWriter out = response.getWriter();
		/* out.print(content+"/n"+perfume+"/n"+ model +"/n"+color); */
		System.out.println();
		User_Inf user_Inf = gu.getUserIdByUsername(username);
		
		Product_Comment pc = new Product_Comment();
		pc.setComment_id(null);
		pc.setProduct_id(3);
		pc.setOrder_id(10);
		pc.setUser_id(5);
		pc.setTitle("sasf");
		pc.setContent(content);
		pc.setAudit_status(0);
		pc.setAudit_time(new Date());
		pc.setModified_time(new Date());
		pc.setModel_id(5);
		MessageDao ad = new MessageDaoImpl();
		boolean b = ad.getMessage(pc);	
		if (b) {
			System.out.println(1111111);
		}
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		doGet(request, response);
	}

}
